Skip to content

zpool/zfs: accept --help and -? after a subcommand#18541

Merged
behlendorf merged 1 commit into
openzfs:masterfrom
chrislongros:fix/zpool-subcommand-help-v2
Jun 4, 2026
Merged

zpool/zfs: accept --help and -? after a subcommand#18541
behlendorf merged 1 commit into
openzfs:masterfrom
chrislongros:fix/zpool-subcommand-help-v2

Conversation

@chrislongros
Copy link
Copy Markdown
Contributor

@chrislongros chrislongros commented May 14, 2026

Motivation and Context

zpool <subcommand> --help and -? prints invalid option '-' followed by the subcommand's usage line, instead of showing help. Same bug for every subcommand. First reported as issue 1 in #17603.

Description

Catch --help and -? after a subcommand, look it up in the command table, and print its short usage. Unknown subcommands fall through to the existing "unrecognized command" error.

How Has This Been Tested?

zpool scrub|checkpoint|create|status|attach|list --help|-? on:

  • Arch Linux 6.19.10 — prints the matching short usage and exits 0.
  • FreeBSD 16.0-CURRENT — same.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the OpenZFS code style requirements.
  • I have updated the documentation accordingly.
  • I have read the contributing document.
  • I have added tests to cover my changes.
  • I have run the ZFS Test Suite with this change applied.
  • All commit messages are properly formatted and contain Signed-off-by.

Comment thread cmd/zpool/zpool_main.c
@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label May 15, 2026
Comment thread cmd/zpool/zpool_main.c Outdated
@chrislongros chrislongros force-pushed the fix/zpool-subcommand-help-v2 branch from 62ca5fb to aeec515 Compare May 23, 2026 10:57
@chrislongros chrislongros changed the title zpool: accept --help, -h, -? after a subcommand zpool/zfs: accept --help, -h, -? after a subcommand May 23, 2026
@behlendorf
Copy link
Copy Markdown
Contributor

It looks like we a few consistent failures which will need to be looked at.

Tests with results other than PASS that are unexpected:
    FAIL cli_root/zfs_diff/zfs_diff_cliargs (expected PASS)
    FAIL cli_root/zfs_diff/zfs_diff_mangle (expected PASS)
    FAIL rsend/send_holds (expected PASS)

Print the short usage instead of "invalid option".

Signed-off-by: Christos Longros <chris.longros@gmail.com>
@chrislongros chrislongros changed the title zpool/zfs: accept --help, -h, -? after a subcommand zpool/zfs: accept --help and -? after a subcommand Jun 4, 2026
@chrislongros chrislongros force-pushed the fix/zpool-subcommand-help-v2 branch from aeec515 to 64834a3 Compare June 4, 2026 14:52
@chrislongros
Copy link
Copy Markdown
Contributor Author

It looks like we a few consistent failures which will need to be looked at.

Tests with results other than PASS that are unexpected:
    FAIL cli_root/zfs_diff/zfs_diff_cliargs (expected PASS)
    FAIL cli_root/zfs_diff/zfs_diff_mangle (expected PASS)
    FAIL rsend/send_holds (expected PASS)

It had to do with the -h prefix.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Jun 4, 2026
@behlendorf behlendorf merged commit a65ed7a into openzfs:master Jun 4, 2026
41 of 46 checks passed
@chrislongros chrislongros deleted the fix/zpool-subcommand-help-v2 branch June 6, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Accepted Ready to integrate (reviewed, tested)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants